package com.jet.sms.remote.member;

import cn.hutool.core.collection.CollUtil;
import com.jet.core.exception.CustomException;
import com.jet.core.result.ResultCode;
import com.jet.core.result.ResultJson;
import com.jet.sms.remote.member.vo.MemberInfoVo;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author dcl
 * @since 2025/2/21 18:20
 */
@Service
public class MemberRemote {

    private final MemberRemoteFeign memberRemoteFeign;

    public MemberRemote(MemberRemoteFeign memberRemoteFeign) {
        this.memberRemoteFeign = memberRemoteFeign;
    }

    public List<MemberInfoVo> getListByMemberIds(long merchantNo, List<String> memberIds) {
        if (CollUtil.isEmpty(memberIds)) {
            return Collections.emptyList();
        }
        ResultJson<List<MemberInfoVo>> result = memberRemoteFeign.getListByMemberIds(merchantNo, memberIds);
        if (result.getCode() != ResultCode.SUCCESS.getCode()) {
            throw new CustomException(result.getMsg());
        }
        return result.getData();
    }
}
